// symbol.js
// Symbol polyfill for WeChat Mini Game

// 如果已经存在 Symbol，则不需要 polyfill
if (typeof GameGlobal.Symbol === 'undefined') {
  // 简单的 Symbol polyfill
  const SymbolPolyfill = function Symbol(key) {
    return `@@${String(key)}`
  }

  // 添加一些常用的 Symbol
  const symbols = {
    iterator: 'Symbol.iterator',
    asyncIterator: 'Symbol.asyncIterator',
    hasInstance: 'Symbol.hasInstance',
    isConcatSpreadable: 'Symbol.isConcatSpreadable',
    match: 'Symbol.match',
    matchAll: 'Symbol.matchAll',
    replace: 'Symbol.replace',
    search: 'Symbol.search',
    species: 'Symbol.species',
    split: 'Symbol.split',
    toPrimitive: 'Symbol.toPrimitive',
    toStringTag: 'Symbol.toStringTag',
    unscopables: 'Symbol.unscopables'
  }

  // 为 Symbol 添加静态属性
  Object.keys(symbols).forEach(key => {
    SymbolPolyfill[key] = SymbolPolyfill(symbols[key])
  })

  // 添加 Symbol 的其他标准方法
  SymbolPolyfill.for = function(key) {
    return SymbolPolyfill(key)
  }

  SymbolPolyfill.keyFor = function(sym) {
    return String(sym).slice(2) // 移除 '@@' 前缀
  }

  // 设置到全局对象
  GameGlobal.Symbol = SymbolPolyfill
} 